package WaiBao;

import java.util.Arrays;

public class ZhangQi {
    public static void main(String[] args) {
        String[] name = {"张冬玲(班长)","白竹(团支书)", "小李(学习委员)","李天蓝(文艺委员)", "张碧蓉", "李飞", "张金柏", "李孟山", "张初阳", "李向天", "戴而言", "李想桥",
                "李语海", "张玲珊", "李凝", "李晓蕾", "张飞莲", "张古翠", "李春蕾", "黄尔蓉", "张冰双", "张怀绿", "韩平宣", "李一株", "张雪瑶", "李寒梅", "黄冰林", "张金凤",
                "李丹寒", "张琪(学生)"};//考生本人: 张琪(学生)
        int[] age = {21, 19, 21, 22, 19, 20, 18, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 21, 19, 20, 21};//最后一位：考生本人年龄:21

        double[] bier1 = {69, 82, 79, 84, 79, 79, 70, 89, 81, 91, 91, 80, 80, 70, 65, 68, 99, 99, 96, 80, 92, 91, 95, 65, 75, 74, 94, 74, 88, 95};
        double[] bier2 = {84, 86, 74, 86, 86, 97, 68, 61, 71, 60, 80, 72, 76, 85, 75, 67, 76, 69, 66, 98, 72, 71, 95, 86, 75, 88, 84, 64, 80, 96};
        double[] bier3 = {90, 69, 80, 95, 76, 69, 78, 64, 80, 80, 73, 87, 85, 65, 65, 65, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 95};


        double sandian1 ;//代表每个学生的总分
        double sandian2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            sandian1 = bier1[i] +bier2[i] +bier3[i];
//            sandian2= (sandian1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" +sandian1);
//            System.out.println(name[i] + "的平均分为:" + sandian2);
//        }


        double them1 = 0,them2= 0;
        double[] yuantong  = new double[30];
//        for (int i = 0; i < 30; i++) {
//            them1 = bier1[i] + bier2[i] + bier3[i];
//            them2 = (them1* 1.0) / 3;
//            yuantong[i] =them2;
//        }
//
//        for (int i = 0; i < yuantong.length - 1; i++) {
//            for (int j = 0; j < yuantong.length - i - 1; j++) {
//                if (yuantong[j] <yuantong [j + 1]) {
//                    double tep = yuantong[j];
//                    yuantong[j] = yuantong[j + 1];
//                    yuantong[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println( yuantong[i]);
//        }



        double lukou1 = 0,  lukou2 = 0, lukou3 = 0;//计算每门课的平均分
        double dida1 = 0, dida2 = 0, dida3 = 0;//计算每门课标准差
        double with1 = 0,  with2 = 0,  with3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < bier1.length; i++) {
            he += bier1[i];
        }
        lukou1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" + lukou1);
        double Sum = 0;
        for (int i = 0; i <bier2.length; i++) {
            Sum +=bier2[i];
        }
        lukou2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" +  lukou2);
        double sum = 0;
        for (int i = 0; i < bier3.length; i++) {
            sum +=bier3[i];
        }
        lukou3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + lukou3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i <bier1.length; i++) {
            c1 += (bier1[i] - lukou1) * (bier1[i] -  lukou1);
        }
        dida1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + dida1);
        for (int i = 0; i <bier2.length; i++) {
            c2 += (bier2[i] - lukou2) * (bier2[i] - lukou2);
        }
        dida2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" + dida2);

        for (int i = 0; i <bier3.length; i++) {
            c3 += (bier3[i] -  lukou3) * (bier3[i] - lukou3);
        }
        dida3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" +  dida3);
////////
//////
//        Arrays.sort(bier1);
//        Arrays.sort(bier2);
//        Arrays.sort(bier3);
//        with1 = (bier1[15] + bier2[16]) * 1.0 / 2;
//        with2 = (bier2[15] +bier2[16]) * 1.0 / 2;
//        with3 = (bier3[15] +bier3[16]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" + with1);
//        System.out.println("农业设施设计与制造的中位数为:" + with2);
//        System.out.println("园艺植物设施栽培学的中位数为:" + with3);








    }
}
